//
//  ChangPassWordViewController.m
//  LoveDraw
//
//  Created by 零零壹 on 2017/11/6.
//  Copyright © 2017年 梁晨. All rights reserved.
//

#import "ChangPassWordViewController.h"

@interface ChangPassWordViewController ()


@end

@implementation ChangPassWordViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"修改密码";
    [self setNavgation];

}

-(void)setNavgation{
    UIColor *bgColor = [UIColor colorWithPatternImage: [UIImage imageNamed:@"nav_bg"]];
    UIView *navigationBar = [[UIView alloc] initWithFrame:CGRectMake(0, 0, MAIN_SCREEN_WIDTH, 64)];
    [navigationBar setBackgroundColor:bgColor];
    //左侧按钮
    UIButton *leftBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 20, 44, 44)];
    [leftBtn setBackgroundImage:[UIImage imageNamed:@"left"] forState:UIControlStateNormal];
    [leftBtn addTarget:self action:@selector(leftOnClick) forControlEvents:UIControlEventTouchUpInside];
    [navigationBar addSubview:leftBtn];

    //中间信息
    UILabel *titLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 20, MAIN_SCREEN_WIDTH, 44)];
    [titLabel setTextColor:[UIColor whiteColor]];
    [titLabel setTextAlignment:1];
    [titLabel setText:@"修改密码"];
    [navigationBar addSubview:titLabel];
    [self.view addSubview:navigationBar];
}

-(void)leftOnClick
{
    [self.navigationController popViewControllerAnimated:YES];
}


- (IBAction)commit:(id)sender
{
    if (self.oldPWD.text.length == 0) {
        [HUD showText:@"请输入旧密码" AfterTime:1];
        return;
    }

    if (self.NewPWD.text.length == 0) {
        [HUD showText:@"请输入新密码" AfterTime:1];
        return;
    }

    [RequestManager HudRequestWithUrl:@"/index.php?g=App&m=StudentInfo&a=alterPassword" parmDic:@{@"oldpassword":self.oldPWD.text,@"password":self.NewPWD.text} requestType:RequestPOST view:self.view Success:^(id data)
    {
        [self.navigationController popViewControllerAnimated:YES];
    } error:^(NSError *error)
    {
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
